﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NTiering.Models;

namespace NTiering.Validators
{
    class SimpleValidator<T> : ISimpleValidator
         where T : class,IDataModel
    {
        IValidator<T> _validator;

        public SimpleValidator(IValidator<T> validator)
        {
            _validator = validator;
        }

        public string Validate(object model,IService currentService)
        {
            var m = model as T;
            if (m == null)
                throw new NullModelException();

            return _validator.Validate(m, currentService); 
        }

    }
}
